//Performance.Stubs.Rules = Singleton.newInstance("core.storage.rule");
//Performance.Stubs.Rules.register("direct.*");
//Performance.Stubs.Rules.register("direct.long.path.*");

Performance.registerGroup({
	name: "storage.rules",
	
	before: function() {
		Env.Core.App.stop();
	},
	
	after: function() {
		Env.Core.App.start();
	}
});

Performance.registerTest({
	group: "storage.rules",
	name: "getNormalizedPath -1-rule -all-same",
	args: [10000, 15000, 25000, 50000],
	
	run: function(arg) {
		var observable = Singleton.newInstance("core.storage.rule");
			observable.register("simple.path.*");
			
		while(arg-- > 0) {
			observable.getNormalizedPath(["simple", "path", "with", "five", "parts"]);
		}
	}
});

Performance.registerTest({
	group: "storage.rules",
	name: "getNormalizedPath -1-rule -50-different",
	args: [10000, 15000, 25000, 50000],

	run: function(arg) {
		var observable = Singleton.newInstance("core.storage.rule");
			observable.register("simple.path.*");
			
		while(arg-- > 0) {
			observable.getNormalizedPath(["simple", "path", "with", "five", "part" + (arg % 50)]);
		}
	}
});

Performance.registerTest({
	group: "storage.rules",
	name: "getNormalizedPath -1-rule -all-different",
	args: [10000, 15000, 25000, 50000],

	run: function(arg) {
		var observable = Singleton.newInstance("core.storage.rule");
			observable.register("simple.path.*");
			
		while(arg-- > 0) {
			observable.getNormalizedPath(["simple", "path", "with", "five", "part" + arg]);
		}
	}
});

Performance.registerTest({
	group: "storage.rules",
	name: "getNormalizedPath -3-rules -all-same",
	args: [10000, 15000, 25000, 50000],

	run: function(arg) {
		var observable = Singleton.newInstance("core.storage.rule");
		for(var i = 0; i < 3; i++) {
			observable.register("simple.path." + i);
		}
		while(arg-- > 0) {
			observable.getNormalizedPath(["simple", "path", "with", "five", "parts"]);
		}
	}
});

Performance.registerTest({
	group: "storage.rules",
	name: "getNormalizedPath -3-rules -50-different",
	args: [10000, 15000, 25000, 50000],

	run: function(arg) {
		var observable = Singleton.newInstance("core.storage.rule");
		for(var i = 0; i < 3; i++) {
			observable.register("simple.path." + i);
		}
		while(arg-- > 0) {
			observable.getNormalizedPath(["simple", "path", "with", "five", "part" + (arg % 50)]);
		}
	}
});

Performance.registerTest({
	group: "storage.rules",
	name: "getNormalizedPath -3-rules -all-different",
	args: [10000, 15000, 25000, 50000],

	run: function(arg) {
		var observable = Singleton.newInstance("core.storage.rule");
		for(var i = 0; i < 3; i++) {
			observable.register("simple.path." + i);
		}
		while(arg-- > 0) {
			observable.getNormalizedPath(["simple", "path", "with", "five", "part" + arg]);
		}
	}
});

Performance.registerTest({
	group: "storage.rules",
	name: "getNormalizedPath -5-rules -all-same",
	args: [10000, 15000, 25000, 50000],

	run: function(arg) {
		var observable = Singleton.newInstance("core.storage.rule");
		for(var i = 0; i < 5; i++) {
			observable.register("simple.path." + i);
		}
		while(arg-- > 0) {
			observable.getNormalizedPath(["simple", "path", "with", "five", "parts"]);
		}
	}
});

Performance.registerTest({
	group: "storage.rules",
	name: "getNormalizedPath -5-rules -50-different",
	args: [10000, 15000, 25000, 50000],

	run: function(arg) {
		var observable = Singleton.newInstance("core.storage.rule");
		for(var i = 0; i < 5; i++) {
			observable.register("simple.path." + i);
		}
		while(arg-- > 0) {
			observable.getNormalizedPath(["simple", "path", "with", "five", "part" + (arg % 50)]);
		}
	}
});

Performance.registerTest({
	group: "storage.rules",
	name: "getNormalizedPath -5-rules -all-different",
	args: [10000, 15000, 25000, 50000],

	run: function(arg) {
		var observable = Singleton.newInstance("core.storage.rule");
		for(var i = 0; i < 5; i++) {
			observable.register("simple.path." + i);
		}
		while(arg-- > 0) {
			observable.getNormalizedPath(["simple", "path", "with", "five", "part" + arg]);
		}
	}
});

Performance.registerTest({
	group: "storage.rules",
	name: "getNormalizedPath -not-found",
	args: [10000, 15000, 25000, 50000],
	
	run: function(arg) {
		var observable = Singleton.newInstance("core.storage.rule");
			
		while(arg-- > 0) {
			observable.getNormalizedPath(["simple", "path", "with", "five", "parts"]);
		}
	}
});

Performance.registerTest({
	group: "storage.rules",
	name: "register: -direct",
	args: [5000, 10000, 15000],
	
	run: function(arg) {
		var observable = Singleton.newInstance("core.storage.rule");
		while(arg-- > 0) {
			observable.register("simple.path.to.hell."+ arg);
		}
	}
});

Performance.registerTest({
	group: "storage.rules",
	name: "register: -child",
	args: [5000, 10000, 15000],
	
	run: function(arg) {
		var observable = Singleton.newInstance("core.storage.rule");
		while(arg-- > 0) {
			observable.register("simple.path.to.*."+ arg);
		}
	}
});
